using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using Microsoft.Practices.PageFlow.Utils;
using Microsoft.Practices.PageFlow;
using System.ComponentModel;
using System.Globalization;

namespace WCSFContrib.PageFlow.Xml.Configuration
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
    public class NavigationGraphConfigurationElement : ConfigurationElementCollection
    {
        public NavigationGraphConfigurationElement()
        {
        }

		[ConfigurationProperty("name", IsRequired = true)]
        public string Name
        {
            get { return (string)base["name"]; }
            set { base["name"] = value; }
        }

        [ConfigurationProperty("statePersist", IsRequired = true)]
        public string StatePersist
        {
            get { return (string)base["statePersist"]; }
            set { base["statePersist"] = value; }
        }

        [ConfigurationProperty("pageFlowType", IsRequired = true)]
        public string PageFlowType
        {
            get { return (string)base["pageFlowType"]; }
            set { base["pageFlowType"] = value; }
        }

        [ConfigurationProperty("startView", IsRequired = true)]
        public string StartView
        {
            get { return (string)base["startView"]; }
            set { base["startView"] = value; }
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings"), ConfigurationProperty("abortUrl", IsRequired = false)]
        public string AbortUrl
        {
            get { return (string)base["abortUrl"]; }
            set { base["abortUrl"] = value; }
        }

        [ConfigurationProperty("abandonable", IsRequired = false)]
        public AbandonBehavior Abandonable
        {
            get { return (AbandonBehavior)base["abandonable"]; }
            set { base["abandonable"] = value; }
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings"), ConfigurationProperty("notRunningUrl", IsRequired = false)]
        public string NotRunningUrl
        {
            get { return (string)base["notRunningUrl"]; }
            set { base["notRunningUrl"] = value; }
        }

        protected override bool ThrowOnDuplicate
        {
            get { return true; }
        }

        public void Add(NodeConfigurationElementCollection node)
        {
            BaseAdd(node);
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
        public bool Contains(string nodeName)
        {
            Guard.ArgumentNotNullOrEmptyString(nodeName, "nodeName");
            return base.BaseGet(nodeName.ToLower(CultureInfo.CurrentCulture)) != null;
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get { return ConfigurationElementCollectionType.BasicMap; }
        }

        protected override string ElementName
        {
            get { return "node"; }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new NodeConfigurationElementCollection();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((NodeConfigurationElementCollection)element).View.ToLower(CultureInfo.CurrentCulture);
        }

        public NodeConfigurationElementCollection this[int index]
        {
            get { return (NodeConfigurationElementCollection)base.BaseGet(index); }
        }

        public new NodeConfigurationElementCollection this[string viewName]
        {
            get
            {
                Guard.ArgumentNotNullOrEmptyString(viewName, "viewName");
                return (NodeConfigurationElementCollection)base.BaseGet(viewName.ToLower(CultureInfo.CurrentCulture));
            }
        }
    }
}
